<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>微信安全支付</title>
    <include file="Template/head"/>
</head>
<body>
<div class="actNav">
    <div class="doRefresh">订单支付</div>
    <a href="javascript:history.go(-1);" class="back"></a>
    <a href="{$domain}" class="home"></a>
</div>

<td class="wapper ucenter" style="overflow: hidden">
    <form method="post" action="{:U('WxJsAPI/jsApiCall')}">
        <input type='hidden' id='orderDetail' value="{:U('WxJsAPI/jsApiCall')}">
        <input type='hidden' id='flightId' name="flightId" value='{$flightId}'>
        <input type="hidden" id="orderNo" name="orderNo" value="{$orderNo}">
        <input type="hidden" id="flightOrderCode" name="flightOrderCode" value="{$flightOrderCode}">
        <input type="hidden" id="seatCode" name="seatCode" value="{$seatCode}">
        <input type="hidden" id="flightNo" name="flightNo" value="{$flightNo}">
        <input type="hidden" id="specialParPrice" name="specialParPrice" value="{$specialParPrice}">
        <input type="hidden" id="code" name="code" value="{$Think.session.flightOrderCode}">
        <input type="hidden" id="openid" name="openid" value="{$openid}">
        <table class="table" style='width:100%'>
            <tr>
                <td class="text-center" colspan="5"><h4>订单详情</h4></td>
            </tr>
            <tr>
                <td class="text-left" colspan="5">航班信息: &nbsp; {$flightNo|substr=0,2|nameToAirLine} {$flightNo}<span
                        style='color:#EC975B'>|</span>{$planeModel}
                </td>
            </tr>
            <tr>
                <th class="text-left" width="20%">乘客</th>
                <th class="text-left" width='15%'>类型</th>
                <th class="text-left" width='29%'>结算价</th>
                <th class="text-left" width='20%'>燃油</th>
                <th class="text-left" width='20%'>基建费</th>
            </tr>
            <foreach name="orderList" item="vo">
                <tr>
                    <td class="text-left" width='15%'>{$vo.passenger_name}</td>
                    <td class="text-left" width='20%'>
                        <if condition="$vo['passenger_type'] eq 0">成人
                            <else/>
                            儿童
                        </if>
                    </td>
                    <td class="text-left" width='20%'>
                        <span class='flight-text-c2'>&yen; {$vo.par_price}</span>
                    </td>
                    <td class="text-left" width='20%'>
                        <span class='flight-text-c2'>&yen;{$vo.fuel_tax}</span>
                    </td>
                    <td class="text-left" width='20%'>
                        <if condition="$vo['passenger_type'] eq 0">
                            <span class='flight-text-c2'>&yen;{$vo.airport_tax}</span>
                            <else/>
                            <span class='flight-text-c2'>&yen;0.00</span>
                        </if>
                    </td>

                </tr>
            </foreach>
            <tr>
                <td class="text-left" colspan="5">起飞日期: &nbsp;{$depDate}</td>
            </tr>
            <tr>
                <td class="text-left" colspan="5">起降机场: &nbsp;
                    {$depTime|returnTime}
                    <if condition="$depCode eq 'NAY'">
                        南苑机场
                        <elseif condition="$depCode eq 'PVG'"/>
                        浦东机场
                        <else/>
                        {$depCode|nameToAirport}
                    </if>
                    <if condition="($orgJetquay eq 'Array') or ($orgJetquay eq '--')">
                        <else/>
                        {$orgJetquay}
                    </if>
                    --

                    {$arrTime|returnTime}
                    <if condition="$arrCode eq 'NAY'">
                        南苑机场
                        <elseif condition="$arrCode eq 'PVG'"/>
                        浦东机场
                        <else/>
                        {$arrCode|nameToAirport}
                    </if>
                    <if condition="($dstJetquay eq 'Array') or ($dstJetquay eq '--')">
                        <else/>
                        {$dstJetquay}
                    </if>
                </td>
            </tr>
            <tr>
                <td class="text-left" colspan="5"><span style='margin-left:10px;'>联系人:</span> &nbsp;{$linkMan}</td>
            </tr>
            <tr>
                <td class="text-left" colspan="5">联系电话: &nbsp;{$linkPhone}</td>
            </tr>
            <tr>
                <td class="text-left" colspan="5">
                    订单总额: &nbsp;
                    <span class="flight-text-c2">&yen;<span class='priceTotal'
                                                            style="font-size:18px;">{$priceTotal}</span></span>
                </td>
            </tr>
            <tr>
                <if condition="$orderFlightInfo['state'] eq 14">
                <td colspan="5" class="text-right showButton">
                    <span class="payContent">
                        <span style="font-size: 20px">您确定要支付吗</span>
                        <button class='btn btn-danger btn-sm doSubmitVisitorFlightOrder' type="button">确定
                        </button>
                    </span>
                </td>
                    <elseif condition="$orderFlightInfo['state'] eq 2"/>
                    <td colspan='5' class='text-right'>
                        <a href="{$redirectUrl}">
                            <input type='button' class='btn btn-info' value="我的机票"/>
                        </a>
                    </td>
                </if>
                <td colspan="5" class="text-right showLoad" style="display:none">
                    <img src="http://cdn.lydlr.com/public/images/load.gif"> <span style="color: #c6c6c6">订单提交中</span>
                </td>

                <td colspan='5' class='text-right showJumpButton' style="display: none">
                    <a href="{$redirectUrl}">
                        <input type='button' class='btn btn-info' value="我的机票"/>
                    </a>
                </td>


            </tr>
        </table>
    </form>

    <div class="modal fade popWin bs-example-modal-sm" id="myModalmob" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title text-center" id="myModalLabel">温馨提示</h4>
                </div>
                <div class="modal-body text-center">
                    <p class="tipsBox"><i class="suc">亲，您最多可以添加6位乘机人</i></p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning doSubmitWarning" data-dismiss="modal"
                            aria-label="Close">确认
                    </button>
                    <button type="button" class="btn btn-default doCloseWarning" data-dismiss="modal"
                            aria-label="Close">取消
                    </button>
                </div>
            </div>
        </div>
    </div>
    <p></p>
    <footer class="footer">
        <include file="Template/foot"/>
    </footer>

    <script>
        $(".doSubmitVisitorFlightOrder").one("click", function() {
            var url = $("#orderDetail").val();
            var fid = $("#flightId").val();
            var openid = $("#openid").val();
            var total = <?php echo $total ?>;
            var creditBalance = <?php echo $creditBalance ?>;

            if(creditBalance < total){
                $("#myModalmob").modal({backdrop: 'static', keyboard: false});
                $("#myModalmob").modal();
                $(".tipsBox").html('系统额度受限,请联系系统管理员');
            }

            $(".doSubmitVisitorFlightOrder").attr("disabled", true);
            $(".showButton").hide();
            $(".showLoad").show();

            $.post(url, {fid:fid,openid:openid},function($data){
                //alert($data['status']);
                if($data['status'] == 2){
                    $(".showLoad").hide();
                    $(".showButton").show();
                    $(".doSubmitVisitorFlightOrder").attr("disabled", false);
                    $("#myModalmob").modal({backdrop: 'static', keyboard: false});
                    $("#myModalmob").modal();
                    $(".tipsBox").html('请勿重复支付');
                }

                if($data['status'] = 1){
                    if (typeof WeixinJSBridge == "undefined"){
                        if( document.addEventListener ){
                            document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                        }else if (document.attachEvent){
                            document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                            document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                        }
                    }else{
                        //jsApiCall();
                        WeixinJSBridge.invoke(
                                'getBrandWCPayRequest',
                                {"appId":$data['appId'],"timeStamp":$data['timeStamp'],"nonceStr":$data['nonceStr'],"package":$data['package'],"signType":$data['signType'],"paySign":$data['paySign']},
                                function(res){
                                    WeixinJSBridge.log(res.err_msg);
                                    //alert(res.err_code+res.err_desc+res.err_msg);
                                    if(res.err_msg == "get_brand_wcpay_request:ok"){
                                        $(".showLoad").hide();
                                        $(".showJumpButton").show();
                                    }
                                }
                        );
                    }
                }
            })

        });

    </script>
    </div>
</body>
</html>